import 'package:json_annotation/json_annotation.dart';

part 'base_response.g.dart';

// 使用泛型语法
@JsonSerializable(genericArgumentFactories: true)
class BaseResponse<T> {
  final int code;
  final bool success;
  final String message;
  final T data;
  final String status;

  BaseResponse({
    required this.code,
    required this.success,
    required this.message,
    required this.data,
    required this.status,
  });

  factory BaseResponse.fromJson(Map<String, dynamic> json, T Function(Object? json) fromJsonT) =>
      _$BaseResponseFromJson(json, fromJsonT);

  Map<String, dynamic> toJson(Object Function(T value) toJsonT) => _$BaseResponseToJson(this, toJsonT);
}